﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Item.Buff
{
    [System.Serializable]
    public struct STBuffEffectData 
    {
        public float fPower, fSpeed, fRange,fGunGroup, fRepel;
        public int nCatapultNum, nPenetrateNum;

        public STBuffEffectData(ST_ItemBuffData[] buffDatas)
        {
            Dictionary<string, float> dicBuffCoefficient = new Dictionary<string, float>();

            if (buffDatas != null)
            {
                ST_ItemBuffData buffData;
                for (int i = 0; i < buffDatas.Length; i++)
                {
                    buffData = buffDatas[i];
                    if (!dicBuffCoefficient.ContainsKey(buffData.strBuffTag))
                        dicBuffCoefficient.Add(buffData.strBuffTag, (float)buffData.dBuffNum + 1f);
                    else
                        dicBuffCoefficient[buffData.strBuffTag] += (float)buffData.dBuffNum;
                }
            }

            fPower = dicBuffCoefficient.ContainsKey(BuffTagConst.Power) ? dicBuffCoefficient[BuffTagConst.Power] : 1;
            fSpeed = dicBuffCoefficient.ContainsKey(BuffTagConst.Speed) ? dicBuffCoefficient[BuffTagConst.Speed] : 1;
            fRange = dicBuffCoefficient.ContainsKey(BuffTagConst.Range) ? dicBuffCoefficient[BuffTagConst.Range] : 1;

            //换写法
            if (!dicBuffCoefficient.TryGetValue(BuffTagConst.Repel, out fRepel)) fRepel = 1;

            fGunGroup = dicBuffCoefficient.ContainsKey(BuffTagConst.GunGroup) ? dicBuffCoefficient[BuffTagConst.GunGroup] : 1;

            nCatapultNum = dicBuffCoefficient.ContainsKey(BuffTagConst.Catapult) ? (int)dicBuffCoefficient[BuffTagConst.Catapult]-1 : 0;
            nPenetrateNum = dicBuffCoefficient.ContainsKey(BuffTagConst.Penetrate) ? (int)dicBuffCoefficient[BuffTagConst.Penetrate]-1 : 0;
        }
    }
}